package com.hx.portal.controller.hospital;


import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.hospital.pojo.Doctor;
import com.hx.hospital.service.DoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/doctor")
@Api(description = "医生相关接口")
public class DoctorController {

    @Reference
    private DoctorService doctorService;

    @ApiOperation(value = "查询所有医生信息" ,notes = "查询所有医生信息",httpMethod = "GET")
    @GetMapping("/findDoctorAll")
    public List<Doctor> findDoctorAll(){
        return doctorService.findDoctorAll();
    }

    @ApiOperation(value = "根据id查询医生信息" ,notes = "根据id查询医生信息",httpMethod = "GET")
    @GetMapping("/findDoctorById")
    public List<Doctor> findDoctorById(Long id){
        return doctorService.findDoctorById(id);
    }

    @GetMapping("/findPage")
    public PageResult<Doctor> findPage(int page, int size){
        return doctorService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Doctor> findList(@RequestBody Map<String,Object> searchMap){
        return doctorService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Doctor> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  doctorService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Doctor findById(Long id){
        return doctorService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Doctor doctor){
        doctorService.add(doctor);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Doctor doctor){
        doctorService.update(doctor);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        doctorService.delete(id);
        return new Result();
    }

}
